package com.hikvision.open.app.utils;

import android.annotation.SuppressLint;
import android.app.Application;
import android.util.Log;


public final class Utils {
    @SuppressLint({"StaticFieldLeak"})
    private static Application sApp;

    private Utils() {
        throw new UnsupportedOperationException("u can't instantiate me...");
    }

    public static void init(Application app) {
        if (app == null) {
            Log.e("Utils", "app is null.");
        } else if (sApp == null) {
            sApp = app;
        } else if (!sApp.equals(app)) {
            sApp = app;
        }
    }

    public static Application getApp() {
        if (sApp != null) {
            return sApp;
        } else {
            throw new NullPointerException("reflect failed.");
        }
    }

}
